using System;

namespace NetFrameworkExtensions.Utils
{
  public class DelegateKeyedReadonlyReference<TKey, TValue> : KeyedReadonlyReferenceBase<TKey, TValue>
  {
    private Func<TKey, TValue> getter;

    public DelegateKeyedReadonlyReference(Func<TKey, TValue> getter)
    {
      if (getter == null) throw new ArgumentNullException("getter");
      this.getter = getter;
    }

    public override TValue this[TKey key]
    {
      get { return getter(key); }
    }
  }
}